package com.west_traveler.tiyutoutiao.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.util.Log;

import com.west_traveler.tiyutoutiao.entity.title_entity.ChannelsBean;
import com.west_traveler.tiyutoutiao.fragment.news_viewpager_fragment.NewsViewPagerFragment;

import java.util.List;

/**
 * Description:
 * created at 2016/12/17 14:56
 *
 * @author: 黄昌友
 */

public class NewsViewPagerAdapter extends FragmentStatePagerAdapter {
    private List<ChannelsBean> title;
    private int[] channel_id;
    private String[] data_version;

    public NewsViewPagerAdapter(FragmentManager fm, List<ChannelsBean> title, int[] channel_id, String[] data_version) {
        super(fm);
        this.title = title;
        this.channel_id = channel_id;
        this.data_version = data_version;
    }

    @Override
    public Fragment getItem(int position) {
        Log.i("TAG", "getItem: " + channel_id[position] +"------>>>>>>"+ data_version[position]);
        return NewsViewPagerFragment.getInstance(channel_id[position], data_version[position]);
    }

    @Override
    public int getCount() {
        return title.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return title.get(position).getName();
    }
}
